package lcr;

public class Test0012 {
}

class Solution0012_1 {
    public int pivotIndex(int[] nums) {
        int sum=0,leftSum=0;
        for (int num : nums) sum+=num;

        for (int i = 0; i < nums.length; i++) {
            int num = nums[i];
            if (leftSum==sum-num-leftSum) return i;
            leftSum+= num;
        }

        return -1;
    }
}